using System;
using System.Text.RegularExpressions;

namespace ADEVSO.Text.RegularExpressions
{
    public class Regex : System.Text.RegularExpressions.Regex
    {
        #region Contructors

        /// <summary>
        /// Create New Regex
        /// </summary>
        /// <param name="pattern">The regular expression pattern to match</param>
        public Regex(String pattern)
            : base(pattern)
        {
        }

        /// <summary>
        /// Create New Regex
        /// </summary>
        /// <param name="pattern">The regular expression pattern to match</param>
        /// <param name="options">A bitwise OR combination of System.Text.RegularExpressions.RegexOptions enumeration values</param>
        public Regex(String pattern, RegexOptions options)
            : base(pattern, options)
        {
        }

        #endregion

        #region Methods

        /// <summary>
        /// Searches the input String for an occurrence of a regular expression 
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <returns></returns>
        public new String Match(String input)
        {
            return Match(input);
        }

        /// <summary>
        /// Searches the input String for an occurrence of a regular expression, beginning at the specified starting position in the String
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="starat">The character position at which to start the search</param>
        /// <returns></returns>
        public new String Match(String input, int startat)
        {
            Match match = base.Match(input, startat);
            return match.Value;            
        }

        /// <summary>
        /// Searches the input String for an occurrence of a regular expression with a specified input String starting position
        /// </summary>
        /// <param name="input">The String to be tested for a match</param>
        /// <param name="beginning">The character position in the input String at which to begin the search</param>
        /// <param name="lenght">The number of characters in the substring to include in the search</param>
        /// <returns></returns>
        public new String Match(String input, int beginning, int lenght)
        {
            Match match = base.Match(input, beginning, lenght);
            return match.Value;
        }

        /// <summary>
        /// Searches the input String for an occurrence of the specified regular expression 
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="pattern">The regular expression pattern to match</param>
        /// <returns></returns>
        public new static String Match(String input, String pattern)
        {
            return System.Text.RegularExpressions.Regex.Match(input, pattern).Value;
        }

        /// <summary>
        /// Searches the input String for an occurrence of the specified regular expression with the specified options
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="pattern">The regular expression pattern to match</param>
        /// <param name="options">A bitwise OR combination of System.Text.RegularExpressions.RegexOptions enumeration values</param>
        /// <returns></returns>
        public new static String Match(String input, String pattern, RegexOptions options)
        {
            return System.Text.RegularExpressions.Regex.Match(input, pattern, options).Value;
        }

        /// <summary>
        /// Searches the specified input String for all occurrence of a regular expression
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <returns></returns>
        public new ADEVSO.Collections.ArrayList Matches(String input)
        {
            return Matches(input, 0);
        }

        /// <summary>
        /// Searches the specified input String for all occurrence of a regular expression, beginning at the specified starting position in the String
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="startat">The character position in the input String at which to start the search</param>
        /// <returns></returns>
        public new ADEVSO.Collections.ArrayList Matches(String input, int startat)
        {
            MatchCollection matches = base.Matches(input, startat);
            ADEVSO.Collections.ArrayList matchess = new ADEVSO.Collections.ArrayList();
            for (int i = 0; i < matches.Count; i++)
                matchess.Add(matches[i].Value);
            return matchess;
        }

        /// <summary>
        /// Searches the input String for all occurrence of the specified regular expression 
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="pattern">The regular expression pattern to match</param>
        /// <returns></returns>
        public new static ADEVSO.Collections.ArrayList Matches(String input, String pattern)
        {
            MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(input, pattern);
            ADEVSO.Collections.ArrayList matchess = new ADEVSO.Collections.ArrayList();
            for (int i = 0; i < matches.Count; i++)
                matchess.Add(matches[i].Value);
            return matchess;
        }

        /// <summary>
        /// Searches the input String for all occurrence of the specified regular expression with the specified options
        /// </summary>
        /// <param name="input">The String to search for a match</param>
        /// <param name="pattern">The regular expression pattern to match</param>
        /// <param name="options">A bitwise OR combination of System.Text.RegularExpressions.RegexOptions enumeration values</param>
        /// <returns></returns>
        public new static ADEVSO.Collections.ArrayList Matches(String input, String pattern, RegexOptions options)
        {
            MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(input, pattern, options);
            ADEVSO.Collections.ArrayList matchess = new ADEVSO.Collections.ArrayList();
            for (int i = 0; i < matches.Count; i++)
                matchess.Add(matches[i].Value);
            return matchess;
        }
        #endregion
    }
}
